package org.vacoor.nothing.misc.express.usps.api.support;

import org.vacoor.nothing.common.xml.JAXB2;
import org.vacoor.nothing.misc.express.usps.api.UspsRequest;
import org.vacoor.nothing.misc.express.usps.api.UspsResult;

/**
 */
public class StdUspsResultBuilder<T> extends AbstractUspsResultBuilder<T> {
    private Class<T> targetType;

    public static <T> UspsResult.Builder<T> create(Class<T> targetType) {
        return new StdUspsResultBuilder<T>(targetType);
    }

    protected StdUspsResultBuilder(Class<T> targetType) {
        this.targetType = targetType;
    }

    @Override
    protected T buildTarget(UspsRequest req, String responseXml) {
        return JAXB2.unmarshal(responseXml, targetType);
    }
}
